<template>
    <div class="content">
      <span class="icon-fanhui" style="color:#2A97F9;font-size: 24px !important;margin-right: 15px;cursor: pointer" @click="goBack()"></span>
      <p class="title">
        详情列表 您可以<el-button type="text" style="font-size: 16px" @click="$refs.dialogImport.init()">继续导入</el-button>，或查看<el-button type="text" style="font-size: 16px" @click="toList()">导入客户</el-button>
      </p>
      <p class="label">
        导入失败记录，共{{total}}条
      </p>

      <el-table
        :data="tableData"
        style="width: 100%;margin-top: 15px">
        <el-table-column
          type="index"
          label="序号"
          width="100">
        </el-table-column>
        <el-table-column
          prop="failure"
          label="失败原因">
        </el-table-column>
        <el-table-column
          prop="record"
          label="记录详情">
        </el-table-column>
      </el-table>

      <div class="footer">
        <el-pagination align="right" class="fixed"
                       @size-change="handleSizeChange"
                       @current-change="handleCurrentChange"
                       :current-page.sync="nowPage"
                       :page-sizes="[10, 20, 30, 50]"
                       :page-size="nowSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="total">
        </el-pagination>
      </div>

<!--   导入弹框   -->
      <DialogImport ref="dialogImport" @updateCust="updateCust"></DialogImport>

    </div>
</template>

<script>
    import DialogImport from '@/components/customer/dialogImport'
    import {custImpDetail} from '@/api/customer'
    export default {
        name: "importDetail",
        data() {
            return {
                tableData:[],
                total:1,
                nowSize:10,
                nowPage:1,
                custId:''
            }
        },
        components:{
            DialogImport
        },
        mounted() {
            this.init()
        },
        methods:{
            init() {
                custImpDetail(this.$route.params.id, this.nowPage, this.nowSize).then(res => {
                    this.custId = res.data.data.records[0].userId
                    this.tableData = res.data.data.records
                    this.total = res.data.data.total
                })
            },
            handleSizeChange(size) {
                this.nowSize = size
                this.init()
            },
            handleCurrentChange(page) {
                this.nowPage = page
                this.init()
            },
            toList() {
                this.$router.push(`/customer/list/${this.custId}`)
            },
            updateCust() {
                this.bus.$emit('updataCustMenu')
            },
            goBack() {
            //   返回上一页，并设置为'客户导入'
                this.$router.push('/customer/admin/3')
            }
        }
    }
</script>

<style scoped>
.content{
  padding: 25px;
  padding-top: 0;
}
  .title{
    font-size: 16px;
    font-weight: 600;
    display: inline-block;
  }
  .label{
    font-size: 13px;
    font-weight: 600;
    margin-top: 10px !important;
  }
</style>
